package 剑指offer.Month7_07.day11;

import java.util.HashSet;
import java.util.Set;

public class 数组中的重复数字 {
    public int duplicate (int[] numbers) {
        // write code here
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < numbers.length; i++) {
            if(set.contains(numbers[i])){
                return numbers[i];
            }else{
                set.add(numbers[i]);
            }
        }
        return -1;
    }
}
